function [discount,beca,stipend] = u38_2012(math,lang,demrecode,his,sci)
%% Universidad Diego Portales
lm=(math+lang)/2;
stipend=zeros(size(lm,1),1);
beca=zeros(size(lm,1),1);

%Beca al M'erito UDP
%beca=max(0,price-ref).*(bea==1);

%Beca puntaje nacional
discount=((math==850) + (lang==850) + (his==850) + (sci==850))>0;

%Beca Excelencia Acad'emica UDP
if demrecode==38170
    auxdiscount=0.25*(lm>=720)+0.25*(lm>=730)+0.25*(lm>=740);
    discount=max(discount,auxdiscount);
end

if demrecode==38004 || demrecode==38005 || demrecode==38171
    auxdiscount=0.25*(lm>=680)+0.25*(lm>=700)+0.25*(lm>=720);
    discount=max(discount,auxdiscount);
end

if demrecode==38083 || demrecode==38162 || demrecode==38003 || demrecode==38163 || demrecode==38172 || demrecode==38173 || demrecode==38323
    auxdiscount=0.25*(lm>=650)+0.25*(lm>=700)+0.25*(lm>=720);
    discount=max(discount,auxdiscount);
end

if demrecode==38080 || demrecode==38174 || demrecode==38175 || demrecode==38176 || demrecode==38292 || demrecode==38006 || demrecode==38015 || demrecode==38285 || demrecode==38164 || demrecode==38166
    auxdiscount=0.25*(lm>=640)+0.25*(lm>=700)+0.25*(lm>=720);
    discount=max(discount,auxdiscount);
end

if demrecode==38032 || demrecode==38009 || demrecode==38013
    auxdiscount=0.25*(lm>=630)+0.25*(lm>=700)+0.25*(lm>=720);
    discount=max(discount,auxdiscount);
end

%BVP, Complemento y Excelencia
if demrecode==38167 || demrecode==38168
    auxdiscount=0.25*(lm>=580).*(lm<600);
    discount=max(discount,auxdiscount);
    [auxdiscount,stipend]=bvp(lm);
    discount=max(discount,auxdiscount);
    stipend=stipend+(lm>=600)*900000;
end

end
